Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor rustc_codegen_ssa #56198

Merged
merged 17 commits into from
Dec 2, 2018
Merged

Refactor rustc_codegen_ssa #56198

merged 17 commits into from
Dec 2, 2018

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Nov 24, 2018

cc #56108 (not all things are done yet)

This removes an unsafe method from cg_ssa.

r? @eddyb
cc @sunfishcode

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 24, 2018
src/librustc_codegen_ssa/traits/statics.rs Show resolved Hide resolved
@@ -98,7 +98,6 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> {
type Value = &'ll Value;
type BasicBlock = &'ll BasicBlock;
type Type = &'ll Type;
type Context = &'ll llvm::Context;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa, this is nice!

@@ -763,6 +763,95 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
}
}
}

fn abort(&mut self) {
let fnname = self.cx().get_intrinsic(&("llvm.trap"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunfishcode I think this builder method should be called trap, wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In cranelift the Interrupt trap can be resumed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Cranelift should add an explicit way to request an "abort" trap.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what should we call this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how bx.abort() lines up with mir::TerminatorKind::Abort. But either way works for me.

#[derive(Copy, Clone)]
pub enum OverflowOp {
Add, Sub, Mul
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@denismerigoux put some enums in common.rs but I'm not sure, this might be better.

src/librustc_codegen_ssa/traits/intrinsic.rs Outdated Show resolved Hide resolved
@eddyb
Copy link
Member

eddyb commented Nov 25, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Nov 25, 2018

📌 Commit 36baa97 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 25, 2018
Usize(u64),
Nullptr,
FnPtr(Instance<'tcx>),
}
Copy link
Member

@eddyb eddyb Nov 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, in case @oli-obk sees this in the meanwhile: I've already told @bjorn3 they can instead use miri to create the whole vtable allocation and just convert that in the backend uniformly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this should be done without an EvalContext. With my recent changes to Allocations this should be mostly possible. I was hoping on getting https://github.com/rust-lang/rust/pull/55392/files#diff-2eb1005fe45cbe73c0ddfcde017b5f73R83 into master before having to address vtable generation, because that function would make such an operation trivial. You can still look at that function as a reference for creating the function that generates a vtable Allocation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code should probably move to rustc::mir::interpret::traits, too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am backing out the vtable generation changes for now, because they are a bit too much work for me right now.

@bjorn3 bjorn3 force-pushed the cg_ssa_refactor branch 2 times, most recently from 8a67d20 to cd66200 Compare November 28, 2018 14:41
@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 29, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0099f33c:start=1543513236546488962,finish=1543513238839969904,duration=2293480942
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---

[00:03:00] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:00] tidy error: /checkout/src/librustc_codegen_llvm/consts.rs:344: TODO is deprecated; use FIXME
[00:03:01] some tidy checks failed
[00:03:01] 
[00:03:01] 
[00:03:01] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:01] 
[00:03:01] 
[00:03:01] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:01] Build completed unsuccessfully in 0:00:54
[00:03:01] Build completed unsuccessfully in 0:00:54
[00:03:01] make: *** [tidy] Error 1
[00:03:01] Makefile:79: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:06e8c59c
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Nov 29 17:43:49 UTC 2018
---
travis_time:end:18261aaa:start=1543513429885035375,finish=1543513429889595057,duration=4559682
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:064d16f0
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:03cf10ef
travis_time:start:03cf10ef
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:22737450
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@eddyb
Copy link
Member

eddyb commented Dec 2, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Dec 2, 2018

📌 Commit d108a91 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 2, 2018
@bors
Copy link
Contributor

bors commented Dec 2, 2018

⌛ Testing commit d108a91 with merge 21f2684...

bors added a commit that referenced this pull request Dec 2, 2018
Refactor rustc_codegen_ssa

cc #56108 (not all things are done yet)

This removes an unsafe method from cg_ssa.

r? @eddyb
cc @sunfishcode
@bors
Copy link
Contributor

bors commented Dec 2, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing 21f2684 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants